home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / putsect.zip / PUTSECT.ASM
Assembly Source File  |  1989-03-20  |  3KB  |  65 lines

  1. ;    Absolute Disk Write:  PUTSEC  ( uses BIOS interrupt 0x26 )
  2. ;
  3. ;    Interfaces to Computer Innovations C-86 "c" compiler V1.32 (& later)
  4. ;    See DOS 2.10 Technical Reference page 5-11, and Technical Reference
  5. ;    page A-32.  This code was written by Mike Sirmans (05-25-84).
  6. ;    --------------------------------------------------------------------
  7. ;       THIS ROUTINE IS POWERFUL. (AND AS SUCH, IS DANGEROUS IN THE WRONG
  8. ;       HANDS).  BE CAREFUL HOW YOU USE IT.  I ASSUME NO RESPONSIBILITY.
  9. ;    --------------------------------------------------------------------
  10. ;
  11. ;    Synopsis:    int putsec(drive,numsec,begsec,buffer)
  12. ;            unsigned int drive;    /* 0=A, 1=B, etc. */
  13. ;            unsigned int numsec;    /* Number of sectors to write */
  14. ;            unsigned int begsec;    /* Beginning logical sector */
  15. ;            char *buffer;        /* Transfer address */
  16. ;
  17. ;    Function:    The number of sectors specified are transferred 
  18. ;            between    the transfer address and the given drive. 
  19. ;            LOGICAL SECTOR NUMBERS are obtained by numbering
  20. ;            each sector sequentially starting from track 0, head 0,
  21. ;            sector 1 (logical sector 0) and continuing along the
  22. ;            same head, then to the next head until the last sector
  23. ;            on the last head of the track is counted.  Thus, 
  24. ;            logical sector 1 is track 0, head 0, sector 2,
  25. ;            logical sector 2 is track 0, head 0, sector 3,  & so on.
  26. ;
  27. ;    Returns:    NULL if the operation is successful.
  28. ;            otherwise, error codes as follows:
  29. ;
  30. ;            hex 80    Attachment failed to respond.
  31. ;            hex 40    SEEK operation failed.
  32. ;            hex 20    Controller failure.
  33. ;            hex 10  Bad CRC on diskette read.
  34. ;            hex 08    DMA overrun on operation.
  35. ;            hex 04    Requested sector not found.
  36. ;            hex 03    Write attempt on write-protected diskette.
  37. ;            hex 02    Address mark not found.
  38. ;            hex FF    Unspecified (error other than those above).
  39. ;
  40. code    segment    byte public        ;segment registers remain intact
  41.     assume    cs:code            ;all other registers will be destroyed
  42.     public    putsec
  43.  
  44. putsec: push    bp            ;save old frame pointer
  45.     mov    bp,sp            ;get new frame pointer
  46.     mov    ax,4[bp]            ;put drive number into AL
  47.     xor    ah,ah
  48.     mov    cx,6[bp]        ;number of sectors to write
  49.     mov    dx,8[bp]        ;logical record number of 1st sector
  50.     mov     bx,10[bp]        ;pointer to transfer address
  51.     int    26h            ;BIOS call
  52.     jc    error            ;error has occurred if carry flag = 1
  53.     mov    al,00H            ;NULL to indicate sucessful completion
  54.     jmp    done
  55. error:    cmp    al,00H            ;detect unspecified error code 00H
  56.     jne    done            ;...change to 0FFh if found to 
  57.     mov    al,0FFH            ;...differentiate it from success code
  58. done:    xor    ah,ah            ;return AL only
  59.     popf                ;remove flags int 0x26 left on stack
  60.     pop    bp            ;restore original frame pointer
  61.     ret                ;all done
  62.  
  63. code    ends
  64.     end
  65.